/********************************************
* Copyrigt (C) rumi
* Module: Serv_CircularBuffer.c
* V1.0.1
*********************************************/
#ifndef Serv_CircularBuffer_H
#define Serv_CircularBuffer_H

/***************************************************/
#include <iostream>
#include <stdbool.h>

/**************************************************/
typedef struct {
    uint8_t *pBuff;       
    uint32_t Size;        
    uint32_t Head;        
    uint32_t Tail;       
}CBuff;

/************************************************/
void CBuff_Init(CBuff *buffer, uint8_t *pBuff, uint32_t size);
uint32_t CBuff_GetLength(const CBuff *buffer);
bool CBuff_Write(CBuff *buffer, const uint8_t *data, uint32_t len);
bool CBuff_Pop(CBuff *buffer, uint8_t *data, uint32_t len);
bool CBuff_Read(CBuff *buffer, uint8_t *data, uint32_t len);
void CBuff_Clear(CBuff *buffer);
bool CBuff_IsEmpty(const CBuff *buffer);
bool CBuff_IsFull(const CBuff *buffer);
uint32_t CBuff_GetFreeSpace(const CBuff *buffer);

#endif // CIRCULAR_BUFFER_H

/*************************************************************************************************
*									END OF FILE
*************************************************************************************************/


